package nowcoder.written_examination.monibishi;

import java.util.Scanner;

/**
 * 校招全国统一模拟笔试技术类编程题参考题解(七月)
 * @author fance
 * @date 18-6-26 上午6:11
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            String[] a = new String[n];
            for (int i = 0; i < n; i++) {
                a[i] = scanner.next();
            }
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n;  j++) {
                    if (isValid(a[i] + a[j])) {
                        cnt++;
                    }
                }
            }
            System.out.println(cnt);
        }
    }
    public static boolean isValid(String s) {
        int status = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == '(') {
                status++;
            } else {
                status--;
            }
            if (status < 0) {
                return false;
            }
        }
        return status == 0;
    }
}
   /* public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String a = scanner.next();
            String b = scanner.next();
            String c = scanner.next();
            if (a.charAt(a.length() - 1) == b.charAt(0) &&
                   b.charAt(b.length() - 1) == c.charAt(0)) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
}*/
   /* public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int k = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                scanner.nextInt();
            }
            int cnt = 0;
            while (n > k) {
                n -= k;
                cnt++;
                n++;
            }
            if (n > 0) {
                cnt++;
            }
            System.out.println(cnt);
        }
    }
}*/
    /*public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = scanner.nextInt();
            }
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                while (a[i] % 2 == 0) {
                    cnt++;
                    a[i] /= 2;
                }
            }
            System.out.println(cnt);
        }
    }
}*/


